<?php
/**
 * 图像加图像水印
 */
/* 打开图片*/
$src = 'img/001.jpg';
$info = getimagesize($src);
$type = image_type_to_extension($info[2], false);
$fun = "imagecreatefrom{$type}";
$image = $fun($src);
/*操作图片*/
$imagemark = 'img/c.png';
$info2 = getimagesize($imagemark);
$type2 = image_type_to_extension($info2[2], false);
$fun2 = "imagecreatefrom{$type2}";

$water = $fun2($imagemark);
imagecopymerge($image, $water, 20, 30, 0, 0, $info2[0], $info2[1], 30);

imagedestroy($water);
/*输出图片*/
header("Content-type: ".$info2['mime']);
$funs = "image{$type}";
$funs($image);
//save picture
$funs($image, 'img/imagemark.'.$type);
/*销毁图片*/
imagedestroy($image);
?>